import { createApp } from 'vue'
import {
  Button,
  List,
  Cell,
  Search,
  Field,
  Icon,
  Toast,
  DropdownMenu,
  DropdownItem,
} from 'vant';
import App from './App.vue'
import "amfe-flexible"

import vant from 'vant';
// 引入组件样式
import 'vant/lib/index.css';
//引入路由
import router from './router/index'
import Tarbar from './layout/tarbar/tarbar.vue';
//引入状态管理
import { createPinia } from 'pinia'
//token的管理
import { useAuthStore } from '@/stores/auth';
// 用户认证拦截器
import { setupInterceptors } from '@/api/interceptors';
import '@/styles/theme.css'


const app = createApp(App);
const pinia = createPinia();
app.use(router);
app.use(Button);
app.use(List);
app.use(Cell);
app.use(Search);
app.use(Field);
app.use(Icon);
app.use(Toast);
app.use(DropdownMenu);
app.use(DropdownItem);
app.use(vant);
app.use(pinia);

// 设置拦截器并传递路由器实例
setupInterceptors(router);

// 在应用启动时清理无效的 token
const authStore = useAuthStore();
if (!authStore.token || authStore.token === 'undefined') {
  authStore.clearToken();
}


app.mount('#app');
